﻿/*
* ============================================================================
* GNU Lesser General Public License
* ============================================================================
*
* BYDAN - Free Java BYDAN library.
* Copyright (C) 2008 
* 
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* 
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
* 
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
* 
* BYDAN Corporation
*/
package ByDan.AulaVirtual.Business.Entities;

import java.util.ArrayList;
import ByDan.Framework.AulaVirtual.Business.Entities.GeneralEntity;
import ByDan.Framework.AulaVirtual.Business.Entities.Mensajes;
import ByDan.Framework.AulaVirtual.Utils.ParameterDbType;
import ByDan.Framework.AulaVirtual.Utils.ParameterType;
import ByDan.Framework.AulaVirtual.Utils.ParametersMaintenance;
import ByDan.Framework.AulaVirtual.Utils.ParameterMaintenance;
import ByDan.Framework.AulaVirtual.Utils.ParameterValue;
import ByDan.Framework.AulaVirtual.Utils.ParametersType;
import java.sql.*;

public class Parrafo extends GeneralEntity
{
	static  String strTableName="Parrafo";
		
	public static String getStrTableName() 
	{
		return strTableName;
	}

	public static void setStrTableName(String strTableName) 
	{
		Parrafo.strTableName = strTableName;
	}
	
	public static String getColumnNameId()
	{
		return "id";
	}
	
	public Parrafo parrafoOriginal;
	
	public Parrafo getParrafoOriginal()
	{
		return parrafoOriginal;
	}
	
	public  void  setParrafoOriginal(Parrafo parrafo)
	{
		try
		{
			parrafoOriginal=parrafo;
		}
		catch(Exception ex)
		{
			;
		}
	}
	
	
	
	
	Pagina relationship_pagina;
	TipoParrafo relationship_tipoparrafo;
	 
	
	public Pagina getRelationship_Pagina()
	{
		return relationship_pagina;
	}

	public TipoParrafo getRelationship_TipoParrafo()
	{
		return relationship_tipoparrafo;
	}

	
	
	public  void  setRelationship_Pagina(Pagina pagina)
	{
		try
		{
			relationship_pagina=pagina;
		}
		catch(Exception ex)
		{
			;
		}
	}


	public  void  setRelationship_TipoParrafo(TipoParrafo tipoparrafo)
	{
		try
		{
			relationship_tipoparrafo=tipoparrafo;
		}
		catch(Exception ex)
		{
			;
		}
	}


	
	
	
	
	
	
	
	private static Boolean blnDeleteCascade=false;
	private static String QueryInsert="insert into aulavirtualme_dbo.Parrafo set ISACTIVE=?,ISEXPIRED=?,VERSIONROW=CURRENT_TIMESTAMP,IDPAGINA=?,IDTIPOPARRAFO=?,PARRAFO=?,ORDEN=?";
	private static String QueryUpdate="update aulavirtualme_dbo.Parrafo set ISACTIVE=?,ISEXPIRED=?,VERSIONROW=CURRENT_TIMESTAMP,IDPAGINA=?,IDTIPOPARRAFO=?,PARRAFO=?,ORDEN=? where id=? AND versionRow=?";
	private static String QueryDelete="delete from aulavirtualme_dbo.Parrafo where id=?";
	public static String QuerySelect="select aulavirtualme_dbo.Parrafo.id,aulavirtualme_dbo.Parrafo.isActive,aulavirtualme_dbo.Parrafo.isExpired,aulavirtualme_dbo.Parrafo.versionRow,aulavirtualme_dbo.Parrafo.IDPAGINA,aulavirtualme_dbo.Parrafo.IDTIPOPARRAFO,aulavirtualme_dbo.Parrafo.PARRAFO,aulavirtualme_dbo.Parrafo.ORDEN from aulavirtualme_dbo.Parrafo";
	 
	Long field_bigIdPagina;
	Long field_bigIdTipoParrafo;
	String field_strParrafo;
	Integer field_intOrden;
				
	public Parrafo ()
    {
		super();		
 		field_bigIdPagina=-1L;
 		field_bigIdTipoParrafo=-1L;
 		field_strParrafo="";
 		field_intOrden=-1;
		
		
		relationship_pagina=new Pagina();
		relationship_tipoparrafo=new TipoParrafo();
		
		
		
		super.setQueryInsert(QueryInsert);
		super.setQueryUpdate(QueryUpdate);
		super.setQueryDelete(QueryDelete);
		super.setQuerySelect(QuerySelect);
		
    } 
	
	public static Boolean getBlnDeleteCascade() 
	{
		return blnDeleteCascade;
	}

	public static void setBlnDeleteCascade(Boolean blnDeleteCascade) 
	{
		Parrafo.blnDeleteCascade = blnDeleteCascade;
	}
	
	public static String getTableName()
    {
         return "aulavirtualme_dbo.Parrafo";
    }
	
    
	public static String getColumnNameidPagina()
	{
		return "idPagina";
	}
    
	public static String getColumnNameidTipoParrafo()
	{
		return "idTipoParrafo";
	}
    
	public static String getColumnNameParrafo()
	{
		return "Parrafo";
	}
    
	public static String getColumnNameOrden()
	{
		return "Orden";
	}
     
    
	public Long getField_bigIdPagina()
	{
		return field_bigIdPagina;
	}
    
	public Long getField_bigIdTipoParrafo()
	{
		return field_bigIdTipoParrafo;
	}
    
	public String getField_strParrafo()
	{
		return field_strParrafo;
	}
    
	public Integer getField_intOrden()
	{
		return field_intOrden;
	}
	
    
	public void setField_bigIdPagina(Long newField_bigIdPagina)throws Exception
	{
		try
		{
			if(this.field_bigIdPagina!=newField_bigIdPagina)
			{
				if(newField_bigIdPagina==null)
				{
					throw new Exception(this.getTableName()+":"+ Mensajes.getMensajeExcepcionValorNulo()+" en columna "+Parrafo.getColumnNameidPagina());
				}

				this.field_bigIdPagina=newField_bigIdPagina;
				this.setIsChanged(true);
			}
		}
		catch(Exception ex)
		{
			throw ex;
		}
	}
    
	public void setField_bigIdTipoParrafo(Long newField_bigIdTipoParrafo)throws Exception
	{
		try
		{
			if(this.field_bigIdTipoParrafo!=newField_bigIdTipoParrafo)
			{
				if(newField_bigIdTipoParrafo==null)
				{
					throw new Exception(this.getTableName()+":"+ Mensajes.getMensajeExcepcionValorNulo()+" en columna "+Parrafo.getColumnNameidTipoParrafo());
				}

				this.field_bigIdTipoParrafo=newField_bigIdTipoParrafo;
				this.setIsChanged(true);
			}
		}
		catch(Exception ex)
		{
			throw ex;
		}
	}
    
	public void setField_strParrafo(String newField_strParrafo)throws Exception
	{
		try
		{
			if(this.field_strParrafo!=newField_strParrafo)
			{
				if(newField_strParrafo==null)
				{
					throw new Exception(this.getTableName()+":"+ Mensajes.getMensajeExcepcionValorNulo()+" en columna "+Parrafo.getColumnNameParrafo());
				}

				this.field_strParrafo=newField_strParrafo;
				this.setIsChanged(true);
			}
		}
		catch(Exception ex)
		{
			throw ex;
		}
	}
    
	public void setField_intOrden(Integer newField_intOrden)throws Exception
	{
		try
		{
			if(this.field_intOrden!=newField_intOrden)
			{
				if(newField_intOrden==null)
				{
					throw new Exception(this.getTableName()+":"+ Mensajes.getMensajeExcepcionValorNulo()+" en columna "+Parrafo.getColumnNameOrden());
				}

				this.field_intOrden=newField_intOrden;
				this.setIsChanged(true);
			}
		}
		catch(Exception ex)
		{
			throw ex;
		}
	}
		
	public  void BuildParametersMaintenance(ParameterDbType newDbType,ParametersType parametersType) throws Exception
	{
		try
		{
			ParametersMaintenance parametersMaintenance=super.getParametersMaintenance();		
			ArrayList<ParameterMaintenance> parametersTemp=new ArrayList<ParameterMaintenance>();
			ParameterMaintenance parameterMaintenance;
			ParameterValue<Long> parameterMaintenanceValueId;
			
				if(!parametersType.equals(ParametersType.DELETE))
				{		
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(1);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.BOOLEAN);
					ParameterValue<Boolean> parameterMaintenanceValueIsactive=new ParameterValue<Boolean>();
					parameterMaintenanceValueIsactive.setValue(this.getIsActive());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueIsactive);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(2);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.BOOLEAN);
					ParameterValue<Boolean> parameterMaintenanceValueIsexpired=new ParameterValue<Boolean>();
					parameterMaintenanceValueIsexpired.setValue(this.getIsExpired());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueIsexpired);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(3);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.LONG);
					ParameterValue<Long> parameterMaintenanceValueIdPagina=new ParameterValue<Long>();
					parameterMaintenanceValueIdPagina.setValue(this.getField_bigIdPagina());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueIdPagina);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(4);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.LONG);
					ParameterValue<Long> parameterMaintenanceValueIdTipoParrafo=new ParameterValue<Long>();
					parameterMaintenanceValueIdTipoParrafo.setValue(this.getField_bigIdTipoParrafo());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueIdTipoParrafo);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(5);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.STRING);
					ParameterValue<String> parameterMaintenanceValueParrafo=new ParameterValue<String>();
					parameterMaintenanceValueParrafo.setValue(this.getField_strParrafo());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueParrafo);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(6);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.INT);
					ParameterValue<Integer> parameterMaintenanceValueOrden=new ParameterValue<Integer>();
					parameterMaintenanceValueOrden.setValue(this.getField_intOrden());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueOrden);
					parametersTemp.add(parameterMaintenance);
					
						if(parametersType.equals(ParametersType.UPDATE))
						{					
							parameterMaintenance=new ParameterMaintenance();
							parameterMaintenance.setOrder(7);
							parameterMaintenance.setParameterMaintenanceType(ParameterType.LONG);
							parameterMaintenanceValueId=new ParameterValue<Long>();
							parameterMaintenanceValueId.setValue(this.getId());
							parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueId);		
							parametersTemp.add(parameterMaintenance);
							
							parameterMaintenance=new ParameterMaintenance();
							parameterMaintenance.setOrder(8);
							parameterMaintenance.setParameterMaintenanceType(ParameterType.TIMESTAMP);
							ParameterValue<Timestamp> parameterMaintenanceValueVersionRow=new ParameterValue<Timestamp>();
							parameterMaintenanceValueVersionRow.setValue(this.getVersionRow());
							parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueVersionRow);		
							parametersTemp.add(parameterMaintenance);					
						}
				}
				else
				{
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(1);
					parameterMaintenance.setParameterMaintenanceType(ParameterType.LONG);
					parameterMaintenanceValueId=new ParameterValue<Long>();
					parameterMaintenanceValueId.setValue(this.getId());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueId);		
					parametersTemp.add(parameterMaintenance);
				}
			
			parametersMaintenance= new ParametersMaintenance();
			parametersMaintenance.setDbType(newDbType);
			parametersMaintenance.setParametersMaintenance(parametersTemp);
			super.setParametersMaintenance(parametersMaintenance);		
		}
		catch(Exception ex)
		{
			throw ex;
		}
	}
}
